<template>
  <div class="MyIllnessLog">
    <van-nav-bar
        title="病情日志"
        left-text=""
        right-text="写日志"
        left-arrow
        @click-left="onClickLeft"
        @click-right="onClickRight"
    />

    <div
        class="MyIllnessLogList"
        v-for="(item, time) in getdieLoglist"
        :key="time"
    >
      <div class="MyIllnessLog">
        <van-cell title="日记"
                  :value="item.time|formatDate"
                  is-link :to="{path:'/Log',query:{date:item.time}}"/>
      </div>
    </div>
  </div>
</template>

<script>
import {formatDate} from "@/utils/date";

export default {
  name: "MyIllnessLog",
  data() {
    return {
      getdieLoglist: [],
    };
  },
  filters: {
    //时间戳转换为日期格式
    formatDate(time) {
      let date = new Date(time);
      return formatDate(date, "yyyy-MM-dd");
    },
  },
  mounted() {
    this.getdieLog();
  },
  methods: {
    //用户记录的病情日记
    getdieLog() {
      //发送请求
      this.$axios({
        url: "http://150.158.153.184:8080/user/select/dieLog",
        method: "post",
      }).then((res) => {
        this.getdieLoglist = res.data.data;
      });
    },
    //显示日志信息
    showIllnessLog() {
    },
    onClickLeft() {
      this.$router.push("/my");
    },
    onClickRight() {
      this.$router.push("/WriteLog");
    },
  },
};
</script>

<style scoped>
.log {
  width: 90%;
  padding: 5%;
  display: flex;
  justify-content: space-between;
}
</style>
